#!/usr/bin/make -f

build: build-stamp

build-stamp:
	./configure
	make
	make -C fcat
	touch build-stamp

install: install-stamp
install-stamp: build-stamp
	dh_testdir
	dh_testroot
	dh_installdirs
	install -m 750 -d debian/openpanel-authd/var/opencore/log
	cp -rf authd.app debian/openpanel-authd/var/opencore/bin/
	ln -sf authd.app/exec debian/openpanel-authd/var/opencore/bin/authd
	cp -rf opencore-tools/* debian/openpanel-authd/var/opencore/tools/
	cp -f fcat/fcat debian/openpanel-authd/var/opencore/tools/
	mkdir -p debian/openpanel-authd/etc/init.d
	install -m 755 contrib/debian.init debian/openpanel-authd/etc/init.d/openpanel-authd
	touch install-stamp

binary-indep: build install

binary-arch: build install
	if [ -d debian/tmp ] ; then dh_install -a --sourcedir=debian/tmp ; fi
	dh_installdocs -a
	dh_installdeb -a
	dh_compress -a
	dh_fixperms -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

binary: binary-indep binary-arch

clean:
	rm -f build-stamp install-stamp
	[ ! -f makeinclude ] || make clean
	dh_clean

.PHONY: build binary binary-arch binary-indep clean install
